<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<div><b>Edit</b> ${attributeSet.name} (<b>Id</b>=${attributeSet.uuid})</div>


<script type="text/javascript">
		function confirmSubmit()
		{
		var agree=confirm("Are you sure you wish to Delete?");
		if (agree)
			return true ;
		else
			return false ;
		}

		function checkEmpty()
		{
	
		v = document.getElementById('attribute.name').value ;
		if ((v == "")) {
    		alert("Enter Attribute name.");
    		return false;        
    		}
		}
	function dis()
	{
		if(document.getElementById('newAttribute').style.display=='block')
		{
			document.getElementById('newAttribute').style.display='none';
		}
		else
		{
			document.getElementById('newAttribute').style.display='block';
		}
	}
</script>

<div id="newAttribute" style="display:none">
	<form method="post" name="createAttribute" action="createAttribute" onsubmit="return checkEmpty()">
		<table>
			<tr><td><b>Name</b></td><td><input type="text" name="attribute.name" id="attribute.name"></td></tr>
			<tr><td><b>Multivalued</b></td><td><select name="attribute.multivalued"><option value="true">true</option><option value="false">false</option></select></td></tr>
			<tr><td></td>
				<td><input type="hidden" name="p" value="${p}">
					<input type="hidden" name="backUrl" value="${backUrl}">
					<input type="hidden" name="pageSize" value="${pageSize}">
					<input type="hidden" name="uuid" value="${attributeSet.uuid}">
					<input type="submit" value="Create"><input type="button" value="Cancel" onclick="dis()">
				</td></tr>
		</table>
	</form>
</div>

<a href="#" onclick="dis()"><b>New Attribute in ${attributeSet.name}</b></a>
<table>
<tr><td><b>Id</b></td><td><b>Name</b></td><td><b>Multivalued</b></td><td><b>Edit</b></td></tr>
<s:if test="attributes.size() > 0">
	<s:iterator value="attributes" var="atr">
		<tr>
			<td>			
				<s:if test="multivalued == true">		
					${atr.uuid}
				</s:if>
				<s:else>
					${atr.uuid}
				</s:else>
			</td>
			<td>${atr.name}</td><td><s:property value="multivalued" /></td>
			<td>
				<s:if test="multivalued == true">
				<a href="editAttribute?uuid=${attributeSet.uuid}&attributeUuid=${atr.uuid}&p=${p}">Edit</a>
				</s:if>
				<s:else>
					Edit
				</s:else>
			</td>
			<td>
				<form name="deleteAttribute" action="deleteAttribute" method="post" onsubmit="return confirmSubmit()">
					<input type="hidden" name="p" value="${p}">
					<input type="hidden" name="backUrl" value="${backUrl}">
					<input type="hidden" name="pageSize" value="${pageSize}">
					<input type="hidden" name="uuid" value="${attributeSet.uuid}">
					<input type="hidden" name="attributeUuid" value="${atr.uuid}">
					<input type="submit" name="delete" value="Delete">
				</form>
			</td>
		</tr>
	</s:iterator>
</s:if>
</table>
<s:iterator value="pageHtml" var="link">
	<a href="editAttributeSet?uuid=${attributeSet.uuid}&p=${link}">${link}</a>
</s:iterator>
<div><a href="${backUrl}"><b>Back</b></a></div>